#include<bits/stdc++.h>
using namespace std;
long long p[100005];
long long ans=0;
vector<int> ans1,ans2;
long long pos[200005];
struct cars
{
    int d,v0,a;
    double k=0;
}c[100005];
long long pow(long long a,long long b)
{
    long long ans=1;
    for(;b;b>>1)
    {
        if(b&1) ans*=a;
        a=a*a;
    }
    return ans;
}
int main()
{
	freopen("detect.in","r",stdin);
	freopen("detect.out","w",stdout);
	double s1=clock(),s2;
    int t;
    cin>>t;
    while(t--)
    {
        int n,m,l,v;
        cin>>n>>m>>l>>v;
        for(int i=0;i<n;i++)
        {
            cin>>c[i].d>>c[i].v0>>c[i].a;
        }
        for(int i=0;i<m;i++)
        {
            cin>>p[i];
        }
        for(int i=0;i<n;i++)
        {
            if(c[i].a==0)
            {
                if(c[i].v0>v&&p[m-1]<=l&&p[m-1]>=c[i].d)
                {
                    ans++;
                }
            }
            else
            {
                double t=(v*1.0-c[i].v0*1.0)/(c[i].a*1.0);

                if(c[i].a>0)
                {
                    //cout<<i<<endl;
                    //cout<<t<<endl;
                    c[i].k=c[i].d*1.0+c[i].v0*1.0*t+0.5*c[i].a*t*t;
                    //cout<<c[i].k<<endl;
                    int cnt=0;
                    for(int j=0;j<m;j++)
                    {
                        if(p[j]>c[i].k&&p[j]<=l)
                        {
                            ans++;
                            pos[j]++;
                            for(int x=j+1;x<m;x++)
                            {
                                if(p[j]>c[i].k&&p[j]<=l)
                                {
                                    pos[x]++;
                                }
                            }
                            break;
                        }
                    }
                    //cout<<ans<<endl;
                }
                else
                {
                    if(c[i].v0<v) continue;
                    //cout<<i<<endl;
                    //cout<<t<<endl;
                    c[i].k=c[i].d*1.0+c[i].v0*1.0*t+0.5*c[i].a*t*t;
                    //cout<<c[i].k<<endl;
                    for(int j=0;j<m;j++)
                    {
                        if(p[j]<c[i].k&&p[j]>=c[i].d)
                        {
                            ans++;
                            pos[j]++;
                            for(int x=j+1;x<m;x++)
                            {
                                if(p[j]<c[i].k&&p[j]>=c[i].d)
                                {
                                    pos[x]++;
                                }
                            }
                            break;
                        }
                    }
                    //cout<<ans<<endl;
                }

            }
        }
        ans1.push_back(ans);
        ans=-1;
        for(int i=0;i<=l;i++)
        {
            ans=max(ans,pos[i]);
        }
        ans2.push_back(ans+1);
    }
    for(int i=0;i<ans1.size();i++)
    {
        cout<<ans1[i]<<" "<<ans2[i]<<endl;
    }
	return 0;
}
